package com.logica.mdm.webfrontend.embedding;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Interface for embedding adapter resolution strategies that allows for
 * both adapter resolution via the request and adapter modification via
 * request and response.
 * @author Fabien Crespel <fabien.crespel@logica.com>
 */
public interface EmbeddingResolver {
	
	/**
	 * Resolve the current embedding adapter via the given request. Should return a
	 * default adapter as fallback in any case.
	 * @param request request to be used for resolution
	 * @return the current embedding adapter
	 */
	EmbeddingAdapter resolveEmbeddingAdapter(HttpServletRequest request);

	/**
	 * Set the current embedding adapter to the given one.
	 * @param request request to be used for embedding adapter modification
	 * @param response response to be used for embedding adapter modification
	 * @param embeddingAdapter the new emebedding adapter 
	 * @throws UnsupportedOperationException if the EmbeddingResolver implementation
	 * does not support dynamic changing of the adapter
	 */
	void setEmbeddingAdapter(HttpServletRequest request, HttpServletResponse response, EmbeddingAdapter embeddingAdapter);
}
